
package ro.qi.framework.sys.security.entities;

import ro.qi.framework.sys.entities.Entity;

public class SecurityAccess extends Entity {

	public static final int NO_ACCESSES		= 9;

	public static final int NO_ACCESS		= 1;
	public static final int DEPOSITOR		= 2;
	public static final int READER			= 3;
	public static final int AUTHOR			= 4;
	public static final int EDITOR			= 5;
	public static final int PUBLISHER		= 6;
	public static final int DESIGNER		= 7;
	public static final int ADMINISTRATOR	= 8;
	public static final int FULL_ACCESS		= 9;

	public static final int ACTION_CREATE_CATEGORY				= 0x0001;
	public static final int ACTION_READ_CATEGORY				= 0x0002;
	public static final int ACTION_MODIFY_CATEGORY				= 0x0004;
	public static final int ACTION_DELETE_CATEGORY				= 0x0008;
	public static final int ACTION_PUBLIC_CREATE_ITEM			= 0x0010;
	public static final int ACTION_PUBLIC_READ_ITEM				= 0x0020;
	public static final int ACTION_PUBLIC_MODIFY_ITEM			= 0x0040;
	public static final int ACTION_PUBLIC_DELETE_ITEM			= 0x0080;
	public static final int ACTION_PRIVATE_CREATE_ITEM			= 0x0100;
	public static final int ACTION_PRIVATE_READ_ITEM			= 0x0200;
	public static final int ACTION_PRIVATE_MODIFY_ITEM			= 0x0400;
	public static final int ACTION_PRIVATE_DELETE_ITEM			= 0x0800;
	public static final int ACTION_PUBLISH						= 0x1000;
	public static final int ACTION_MANAGE_SETTINGS				= 0x2000;
	public static final int ACTION_MANAGE_ACL					= 0x4000;

	public static final String[] NAME = new String[]{
		"nothin'",
		"No Access",
		"Depositor",
		"Reader",
		"Author",
		"Editor",
		"Publisher",
		"Designer",
		"Administrator",
		"Full Access"
	};

	public static final int[] MASK = new int[]{
		// NOTHIN'
		0,
		// NO_ACCESS
		0,
		// DEPOSITOR
		ACTION_READ_CATEGORY | ACTION_PUBLIC_CREATE_ITEM | ACTION_PRIVATE_CREATE_ITEM,
		// READER
		ACTION_READ_CATEGORY | ACTION_PUBLIC_READ_ITEM | ACTION_PRIVATE_READ_ITEM,
		// AUTHOR
		ACTION_READ_CATEGORY | 
		ACTION_PRIVATE_CREATE_ITEM | ACTION_PRIVATE_READ_ITEM | ACTION_PRIVATE_MODIFY_ITEM | ACTION_PRIVATE_DELETE_ITEM, 
		// EDITOR
		ACTION_READ_CATEGORY | 
		ACTION_PUBLIC_CREATE_ITEM | ACTION_PUBLIC_READ_ITEM | ACTION_PUBLIC_MODIFY_ITEM | ACTION_PUBLIC_DELETE_ITEM |
		ACTION_PRIVATE_CREATE_ITEM | ACTION_PRIVATE_READ_ITEM | ACTION_PRIVATE_MODIFY_ITEM | ACTION_PRIVATE_DELETE_ITEM,
		// PUBLISHER
		ACTION_READ_CATEGORY | 
		ACTION_PUBLIC_READ_ITEM | 
		ACTION_PRIVATE_READ_ITEM | 
		ACTION_PUBLISH, 
		// DESIGNER
		ACTION_CREATE_CATEGORY | ACTION_READ_CATEGORY | ACTION_MODIFY_CATEGORY | ACTION_DELETE_CATEGORY | 
		ACTION_PUBLIC_CREATE_ITEM | ACTION_PUBLIC_READ_ITEM | ACTION_PUBLIC_MODIFY_ITEM | ACTION_PUBLIC_DELETE_ITEM |
		ACTION_PRIVATE_CREATE_ITEM | ACTION_PRIVATE_READ_ITEM | ACTION_PRIVATE_MODIFY_ITEM | ACTION_PRIVATE_DELETE_ITEM |
		ACTION_PUBLISH | ACTION_MANAGE_SETTINGS,
		// ADMINISTRATOR
		ACTION_MANAGE_ACL, 
		// FULL_ACCESS
		ACTION_CREATE_CATEGORY | ACTION_READ_CATEGORY | ACTION_MODIFY_CATEGORY | ACTION_DELETE_CATEGORY | 
		ACTION_PUBLIC_CREATE_ITEM | ACTION_PUBLIC_READ_ITEM | ACTION_PUBLIC_MODIFY_ITEM | ACTION_PUBLIC_DELETE_ITEM |
		ACTION_PRIVATE_CREATE_ITEM | ACTION_PRIVATE_READ_ITEM | ACTION_PRIVATE_MODIFY_ITEM | ACTION_PRIVATE_DELETE_ITEM |
		ACTION_PUBLISH | ACTION_MANAGE_SETTINGS | ACTION_MANAGE_ACL 
	};

	public SecurityAccess() {
		super();
	}

//	public SecurityAccess(int accessId, int applicationId, int userId, int groupId) {
//		super();
//		setAccessId(accessId);
//		setApplicationId(applicationId);
//		setUserId(userId);
//		setGroupId(groupId);
//	}
//
//	public void setAccessId(int value) {
//		setValue("accessId", value);
//	}
//
//	public int getAccessId() {
//		return getIntValue("accessId");
//	}
//
//	public void setApplicationId(int value) {
//		setValue("applicationId", value);
//	}
//
//	public int getApplicationId() {
//		return getIntValue("applicationId");
//	}
//
//	public void setUserId(int value) {
//		setValue("userId", value);
//	}
//
//	public int getUserId() {
//		return getIntValue("userId");
//	}
//
//	public void setGroupId(int value) {
//		setValue("groupId", value);
//	}
//
//	public int getGroupId() {
//		return getIntValue("groupId");
//	}
//
//	public void setAccessMask(int value) {
//		setValue("accessMask", value);
//	}
//
//	public int getAccessMask() {
//		return getIntValue("accessMask");
//	}

}
